﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Elysium.Demo;
using SIIE_ERP.Codigo;
using SIIE_ERP.View;
using SIIE_ERP.BaseDatos;

namespace Elysium.Demo.Informes
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class Seleccion_PuntoVenta_Tickets : UserControl
    {
        private UsuarioActivo _sesion;
        private string _RutaReporte;
        bool IsReportEmbedded;

        public Seleccion_PuntoVenta_Tickets(ref UsuarioActivo usuario, string RutaReporte, bool IsReportEmbedded = false)
        {
            InitializeComponent();
            this._sesion = usuario;
            this._RutaReporte = RutaReporte;

            CargarCombos();

            if (IsReportEmbedded)
                ButtonRegresar.Visibility = System.Windows.Visibility.Hidden;
            this.IsReportEmbedded = IsReportEmbedded;
        }

        public void CargarCombos()
        {
            ComboBoxUI.ComboTiempo(ref Combo_Tiempo);
            ComboBoxUI.ComboTerminales(Combo_Terminal, _sesion);            
        }

        private void ButtonRegresar_Click(object sender, RoutedEventArgs e)
        {
            Viewbox Aux = (Viewbox)this.Parent;
            Aux.Child = null;
            Aux.Child = new Menu_Informes(ref _sesion);           
        }

        private void Button_Aceptar_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                int Tiempo = Int32.Parse(((CItem)Combo_Tiempo.SelectedItem).Id);
                int Terminal = Int32.Parse(((CItem)Combo_Terminal.SelectedItem).Id);

                Viewbox Aux = (Viewbox)this.Parent;
                Aux.Child = null;
                Aux.Child = new GenericReport(ref _sesion, _RutaReporte, Tiempo, Terminal, IsReportEmbedded);
            }
            catch (Exception Ex)
            {
                MessageBox.Show("Necesita tener Terminales en su sistema para visualizar este reporte.");
            }
        }        
    }
}

